using System.Collections.ObjectModel;
using Caliburn.Micro;

namespace CitiSurface
{
    /**
     * This is the datacontext used in the IdTagVisualization view
     * All the datas are set in the ShellViewModel
     */
    public class IdTagViewModel : PropertyChangedBase
    {
        private Interviewee _interviewee;
        public Interviewee Interviewee
        {
            get { return _interviewee; }
            set
            {
                if(_interviewee != value)
                {
                    _interviewee = value;
                    NotifyOfPropertyChange(() => Interviewee);
                }
            }
        }
        
        /**
         * Shorthand for Interviews
         */
        public ObservableCollection<Interview> Interviews
        {
            get { return _interviewee != null ? _interviewee.Interviews : null; }
        }

        private ObservableCollection<Interviewer> _interviewers; 
        public ObservableCollection<Interviewer> Interviewers
        {
            get
            {
                if (_interviewee == null) return null;
                
                if(_interviewers == null)
                {// init for first use
                    _interviewers = new ObservableCollection<Interviewer>();
                    foreach(var interview in _interviewee.Interviews)
                    {
                        _interviewers.Add(interview.Interviewer);
                    }
                }
                return _interviewers;
            }
        }
    }
}
